$('.right-titleicon').on("click",function(e){
	projectVM.showMenulist()
})
let that;
projectVM = new Vue({
	el: "#content",
	data: {
		disabled:true,
		showSelect:false,
		menuList:[
			{name:'投入',path:'goIn.html'},{name:'退出',path:'goOut.html'},{name:'列表',path:'index.html'},
		],
		typeList:[{name:'变压器1'},{name:'变压器2'},{name:'变压器3'},{name:'变压器4'},],
		showSubmit:false,
		onStatus:'',
		selectText:'变压器1',
		result:'',
		showMenu:false,
		showMorebtn:false,
		advance:'',
		showAdd:false,
		show_popup:false,
		OperateStaff:"",//操作人
		TutelageStaff:"",//监护人
		listin:[],
		fileList:[],
		listout:[],
	},
	created: function() {
		that = this;
		//hu获取页面必要的参数
		let config = mui.neioConfig.getNeioConfig();
		let key = config.KEYS.PLATENDATA;
		let data = mui.neioConfig.getStorage(key);
		let dataJson = JSON.parse(data)
		that.OperateStaff = dataJson.inOperateStaffName == null ?  "["+dataJson.outOperateStaffCode+"]"+dataJson.outOperateStaffName : "["+dataJson.inOperateStaffCode+"]"+dataJson.inOperateStaffName
		that.TutelageStaff = dataJson.inTutelageStaffName == null ?  "["+dataJson.outTutelageStaffCode+"]"+dataJson.outTutelageStaffName : "["+dataJson.inTutelageStaffCode+"]"+dataJson.inTutelageStaffName
		that.getoutDetail(dataJson)
		that.getInDetail(dataJson)
		// that.getPlateInfoByWorkId();
	},
	methods: {
		//根据workid获取保护压板详情
		getPlateInfoByWorkId(){
			let config = mui.neioConfig.getNeioConfig();
			let url = config.URL.queryPlateInfoByWorkId;
			//详情数据的Key
			console.log("OPOPOP:"+url)
			let items = JSON.parse(localStorage.getItem('neiosGoDetail'));
			that.workId = items.obj.workId
			let param = {};
			param.workId = that.workId
			
			mui.neiosRequst.httpRequst(url,param,function(ret){
			console.log("投入成功回掉："+JSON.stringify(ret))
				if(ret.code == 0){
					if('0208' == items.obj.workType){
						//退出
						that.listout = ret.data;
						that.getFileList(ret.attachIds);
					}
					if('0205' == items.obj.workType){
						//投入
						that.listin = ret.data;
						that.getFileList(ret.attachIds);
					}
					that.OperateStaff = '['+ret.operateStaffCode+']'+ret.operateStaffName
					that.TutelageStaff = '['+ret.tutelageStaffCode+']'+ret.tutelageStaffName
				}
			},function(err){
				console.log("失败回掉："+JSON.stringify(err))
			})
		},
		//获取投入详情
		getInDetail(data){
			if(data.inOperateId == null || data.inOperateId == "" || data.inOperateId == undefined){
				return;
			}
			let config = mui.neioConfig.getNeioConfig();
			let url = config.URL.queryPlateInfoById
			let params = {}
			params.inOperateId = data.inOperateId;
			params.plateCode = data.plateCode;
			mui.neiosRequst.httpRequst(url,params,function(ret){
			console.log("投入成功回掉："+JSON.stringify(ret))
				if(ret.code == 0){
					that.listin = ret.data;
					that.getFileList(ret.attachIds);
				}
			},function(err){
				console.log("失败回掉："+JSON.stringify(err))
			})
		},
		//获取退出详情
		getoutDetail(data){
			if(data.outOperateId == null || data.outOperateId == "" || data.outOperateId == undefined){
				return;
			}
			let config = mui.neioConfig.getNeioConfig();
			let url = config.URL.queryPlateInfoById
			let params = {}
			params.outOperateId = data.outOperateId;
			params.plateCode = data.plateCode;
			mui.neiosRequst.httpRequst(url,params,function(ret){
				console.log("退出成功回掉："+JSON.stringify(ret))
				if(ret.code == 0){
					that.listout = ret.data;
					that.getFileList(ret.attachIds);
				}
			},function(err){
				console.log("失败回掉："+JSON.stringify(err))
			})
		},
		//根据attachIds（网络获取）获取文件列表
		getFileList(attachIds){
			let config = mui.neioConfig.getNeioConfig();
			let url = config.URL.getFileList
			let params = {}
			params.fileIds = attachIds;
			mui.neiosRequst.httpRequst(url,params,function(ret){
				console.log("文件列表获取回掉："+JSON.stringify(ret))
				if(ret.code == 0){
					that.fileList = ret.data
				}
			},function(err){
				console.log("失败回掉："+JSON.stringify(err))
			})
		},
		downloadFile(position){
			let url = "/app/common/downloadFile";
			let param = {};
			param.fileId = that.fileList[position].fileId;
			mui.neiosCommon.downLoadFile(param,function(ret){
				mui.plusReady(function () {
					plus.nativeUI.closeWaiting();
				})
				//调用存储
				var callbackID = plus.bridge.callbackId(function(ret){
					mui.toast(ret[0])
				}, function(err){
					mui.toast('文件下载失败')
				});
				let fileName = that.fileList[position].fileName
				plus.bridge.execSync( "FileHelper", "doFileSave", [callbackID, ret, fileName, "Argus3", "Argus4"] )
			},function(err){
				mui.plusReady(function () {
					plus.nativeUI.closeWaiting();
				})
				mui.toast('文件下载失败')
			});
			
		},
		//选择变压器类型
		chooseType(e){
			console.log(e,'===')
		},
		//返回上一页
		goBack(){
			mui.back()
		},
		//更多按钮
		showMore(){
			this.showMorebtn ? this.showMorebtn = false : this.showMorebtn = true
		},
		//阻止事件冒泡
		clickStop(){

		},
		//选择是否为值班人
		checkOnstatus(){
			console.log(this.onStatus)
			this.onStatus ? this.onStatus = false : this.onStatus =true
			
		},
		//点击菜单
		menuClick(e){
			if(e.name == '我值班'){
				this.onStatus? this.onStatus= false : this.onStatus=true
			}else{
				this.navTo(e.path)
			}
		},
		//左上角菜单显示隐藏
		showMenulist(){
			this.showMenu?this.showMenu=false:this.showMenu=true
		},
		navTo(e){
			mui.openWindow({
					url: e,
					id: e,
			});
			}
	},
	
	})